#ifndef _MODBUS_H_
#define _MODBUS_H_

#include "sys_hc32f460.h"
#include "systemdata.h"


#define  ReadInputRegRegData   	   0x04			//读输入寄存器
#define  ReadHoldRegRegData    	   0x03			//读保持寄存器
#define  WriteSinHoldRegRegData    0x06			//单个保持寄存器写入
#define  WriteMulHoldRegRegData    0x10			//多个保持寄存器写入
#define  ForcedSingleCoil		   0x05			//强制单线圈
#define  ExtendedFunction          0x80         //扩展功能
#define  StartUpgrade  	   	  	   0x81			//启动升级
#define  SystemCali  	   	  	   0x82			//系统校准

//子功能码
#define  ReadFaultProfile  	   	   0x01			//读取故障概况
#define  ClearFaultProfile  	   0x02			//清除故障概况
#define  ReadFaultLog  	   	   	   0x03			//读取故障日志
#define  ClearFaultLog  	   	   0x04			//清除故障日志


void modbus_data(uint8_t *data,uint16_t len,uint8_t comNum);
void modbus_data_parse(uint8_t *data,uint16_t len,uint8_t comNum);
#endif
